package com.task.web.controller.core;

import javax.annotation.Resource;

import com.task.core.vo.resp.DeviceFraudDetailVo;
import com.task.core.vo.resp.ProxyDetailRespVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.task.common.annotation.Log;
import com.task.common.core.controller.BaseController;
import com.task.common.core.domain.AjaxResult;
import com.task.common.core.page.TableDataInfo;
import com.task.common.enums.BusinessType;
import com.task.common.utils.SecurityUtils;
import com.task.core.dto.request.DeviceFraudRequestDTO;
import com.task.core.service.CheckService;
import com.task.core.service.DeviceFraudService;

import io.swagger.annotations.Api;

/**
 * @author 迪迦.
 * @date 2024/11/4 14:29
 */
@Api("")
@RestController
@RequestMapping("/deviceFraud")
public class DeviceFraudController extends BaseController {


  @Resource
  private DeviceFraudService deviceFraudService;

  @Resource
  private CheckService checkService;


  @PreAuthorize("@ss.hasPermi('deviceFraud:list')")
  @GetMapping("/getDeviceFraudByPage")
  public TableDataInfo getDeviceFraudByPage(DeviceFraudRequestDTO request) {
    startPage(request.getPageNum(), request.getPageSize());
    return getDataTable(deviceFraudService.getDeviceFraudByPage(request));
  }


  @PreAuthorize("@ss.hasPermi('deviceFraud:option')")
  @GetMapping("/getDeviceFraudForOption")
  public TableDataInfo getDeviceFraudForOption(DeviceFraudRequestDTO request) {
    return getDataTable(deviceFraudService.getDeviceFraudForOption(request));
  }

  @Log(title = "DeviceFraud管理", businessType = BusinessType.INSERT)
  @PostMapping("/addDeviceFraud")
  public AjaxResult addDeviceFraud(@RequestBody DeviceFraudRequestDTO request) {
    request.setOperationBy(SecurityUtils.getLoginUser().getUserId());
    deviceFraudService.addDeviceFraud(request);
    return success();
  }

  @Log(title = "DeviceFraud管理", businessType = BusinessType.UPDATE)
  @PutMapping("/modifyDeviceFraud")
  public AjaxResult modifyDeviceFraud(@RequestBody DeviceFraudRequestDTO request) {
    checkService.check("data_device_fraud", request.getCode());
    request.setOperationBy(SecurityUtils.getLoginUser().getUserId());
    deviceFraudService.modifyDeviceFraud(request);
    return success();
  }

  @Log(title = "DeviceFraud管理", businessType = BusinessType.DELETE)
  @DeleteMapping("/deleteDeviceFraud/{DeviceFraudCode}")
  public AjaxResult deleteDeviceFraud(@PathVariable String DeviceFraudCode) {
    checkService.check("data_device_fraud", DeviceFraudCode);
    deviceFraudService.deleteDeviceFraud(DeviceFraudCode, SecurityUtils.getLoginUser().getUserId());
    return success();
  }
  @GetMapping ("/getDeviceFraudDetail/{deviceFraudCode}")
  @PreAuthorize("@ss.hasPermi('system:deviceFraud:edit')")
  public AjaxResult getDeviceFraudDetail(@PathVariable String deviceFraudCode) {
    checkService.check("data_device_fraud", deviceFraudCode);
    DeviceFraudDetailVo deviceFraudDetailVo  = deviceFraudService.getDeviceFraudDetail(deviceFraudCode);
    return success(deviceFraudDetailVo);
  }

}
